package tichu_project252.View.Player;

import javax.swing.JButton;
import tichu_project252.Controller.passHandler;
import tichu_project252.Model.Model;

/**
 * This class implements the event handler of playing pass button.
 *
 * This action listener is implemented to define what should be done when a
 * user push the Pass button.
 *
 * @see <a
 * href="http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html">actionListener</a>
 *
 * @author Alexandra Barka, ΑΜ: 2867, login : barka.
 * @version %I%, %G%
 */
public class passButton extends JButton {

    private int player;

    /**
     * Constructs a Push button.
     * 
     * 
     * <p><b>Constructor: </b> passButton(Model m, int player) </p>
     *
     * <p><b>Precondition: </b> </p> <p><b>Postcondition: </b> Constructs a new
     * JButton </p>
     * 
     * @param m The model
     * @param player  The player who push the button
     */
    public passButton(Model m, int player) {
        super("Pass");
        this.player = player;
        this.addActionListener(new passHandler(m));
    }

    /**
     * Returns the player who hhad pushed the Pass button.
     *
     * <p> <b> Accessor: </b> getPlayer() </p>
     *
     * <p><b> Precondition: </b> The player is valid</p>
     *
     * </p> <p> <b> Postcondition:</b> Returns the player. </p>
     *
     * @return The player who has pushed the button
     */
    public int getPlayer() {
        return this.player;
    }
}
